{template '_header'}
<style type='text/css'>
    .moresearch { padding:0px 10px;}
    .moresearch .col-sm-2 {
        padding:0 5px
    }
    .popover{
        width:170px;
        font-size:12px;
        line-height: 21px;
        color: #0d0706;
    }
    .popover span{
        color: #b9b9b9;
    }
    .nickname{
        display: inline-block;
        max-width:200px;
        overflow: hidden;
        text-overflow:ellipsis;
        white-space: nowrap;
        vertical-align: middle;
    }

    .tooltip-inner{
        border:none;
    }
    .info{
        height: 100%;
        width:370px;
        float:left;
        border-right:1px solid #efefef;
        padding: 40px 20px;
        line-height: 25px;
    }
    .info i{
        display: inline-block;
        width:80px;
        text-align: right;
        color: #999;
    }
    ._cover {
        color: #337ab7 !important;
    }
</style>
<div class="page-header">
    当前位置：<span class="text-primary">一级下线 <small>总数: <span class='text-danger'>{$total}</span></small></span>
</div>
<div class="page-content">
    <div class="page-sub-toolbar">
        <span class=''>
            <a class="btn btn-default  btn-sm" href="{php echo webUrl('commission/agent')}">返回列表</a>
        </span>
    </div>
<div style="height: 180px;border: 1px solid #efefef;margin-bottom: 30px">
        <div class="info">
            <img class="pull-left" src='{$member['avatar']}' style='width:100px;height:100px;border:1px solid #ccc;padding:1px'  onerror="this.src='../addons/ewei_shopv2/static/images/noface.png'"/>
           <div class="pull-left">
              <i> 昵称：</i>{$member['nickname']}<br/>
              <i> 姓名：</i>{$member['realname']} <br/>
               <i>手机号：</i>{$member['mobile']} <br/>
               <i>微信号：</i> {$member['weixin']}<br/>
           </div>
        </div>
    <div class="info" style="text-align: center">
        <div class="pull-left">
            <i> 上级分销商：</i>{php echo $parentInfo['nickname'] ? : "总店"}<br/>
            <i> 姓名：</i>{$parentInfo['realname']} <br/>
            <i>手机号：</i>{$parentInfo['mobile']} <br/>
            <i>微信号：</i> {$parentInfo['weixin']}<br/>
            <!--分享链接首次点击次数： <span class="text-danger">{$member['clickcount']}</span> 次-->
        </div>
    </div>
        <div class="info" style="text-align: center">
            <p class="pull-left" style="color: #999;width: 120px;"> 下级分销商：</p>
            <div  class="pull-left">
                总共：<span>{$member['agentcount']}</span> 人<br/>
                {if $this->set['level']>=1}一级：<a class="_cover" href="{php echo webUrl('commission/agent/user', array('level' => 1,'id' => $_GPC['id']))}">{$level1} </a>  人{/if}<br/>
                {if $this->set['level']>=2}二级：<a class="_cover" href="{php echo webUrl('commission/agent/user', array('level' => 2, 'id' => $_GPC['id']))}">{$level2}</a>  人{/if}<br/>
                {if $this->set['level']>=3}三级： <a class="_cover" href="{php echo webUrl('commission/agent/user', array('level' => 3, 'id' => $_GPC['id']))}">{$level3}</a> 人{/if}<br/>
<!--                分享链接首次点击次数： <span class="text-danger">{$member['clickcount']}</span> 次-->
            </div>
        </div>
        <div style="padding: 40px 20px;float: left">
            下级会员(非分销商): <span style='color:red'>{$level11}</span> 人    <br/>
        </div>
        <div style="clear: both"></div>
</div>

<form action="./index.php" method="get" class="form-horizontal" role="form" id="form1">
    <input type="hidden" name="c" value="site" />
    <input type="hidden" name="a" value="entry" />
    <input type="hidden" name="m" value="ewei_shopv2" />
    <input type="hidden" name="do" value="web" />
    <input type="hidden" name="r" value="commission.agent.user" />
    <input type="hidden" name="id" value="{$agentid}" />
    <div class="page-toolbar m-b-sm m-t-sm ">
        <div class="col-sm-12 pull-right">
            <span class="pull-left">
                 {php echo tpl_daterange('time', array('sm'=>true, 'placeholder'=>'成为分销商时间'),true);}
            </span>
            <div class="input-group">
                <span class="input-group-select">
                     <select name='isagent'  class='form-control  input-sm'  >
                         <option value=''>是否分销商</option>
                         <option value='0' {if $_GPC['isagent']=='0'}selected{/if}>不是</option>
                         <option value='1' {if $_GPC['isagent']=='1'}selected{/if}>是</option>
                     </select>
                </span>


<!--                <span class="input-group-select">-->
<!--                     <select name='level' class='form-control  input-sm' >-->
<!--                         <option value=''>下线层级</option>-->
<!--                         {if $this->set['level']>=1}<option value='1' {if $_GPC['level']=='1'}selected{/if}>一级下线</option>{/if}-->
<!--                         {if $this->set['level']>=2}<option value='2' {if $_GPC['level']=='2'}selected{/if}>二级下线</option>{/if}-->
<!--                         {if $this->set['level']>=3}<option value='3' {if $_GPC['level']=='3'}selected{/if}>三级下线</option>{/if}-->
<!--                     </select>-->
<!--                </span>-->


                <span class="input-group-select">
                     <select name='followed' class='form-control  input-sm'>
                         <option value=''>关注</option>
                         <option value='0' {if $_GPC['followed']=='0'}selected{/if}>未关注</option>
                         <option value='1' {if $_GPC['followed']=='1'}selected{/if}>已关注</option>
                         <option value='2' {if $_GPC['followed']=='2'}selected{/if}>取消关注</option>
                     </select>
                </span>

                <span class="input-group-select">
                    <select name='isagentblack'  class='form-control  input-sm'    >
                        <option value=''>黑名单</option>
                        <option value='0' {if $_GPC['isagentblack']=='0'}selected{/if}>否</option>
                        <option value='1' {if $_GPC['isagentblack']=='1'}selected{/if}>是</option>
                    </select>
                </span>

                <input type="text" class="form-control input-sm"  name="keyword" value="{$_GPC['keyword']}" placeholder="昵称/姓名/手机号"/>
                <input type="hidden" value="{$_GPC['level']}" name="level">
				 <span class="input-group-btn">
                     <button class="btn  btn-primary" type="submit"> 搜索</button>
                     <button type="submit" name="export" value="1" class="btn btn-success ">导出</button>

				</span>
            </div>

        </div>
    </div>
    {if count($list)>0}

    <table class="table table-hover table-responsive">
        <thead class="navbar-inner" >
        <tr>

            <th>粉丝</th>
            <th>姓名<br/>手机号码</th>
            <th>下线层级</th>
            <th >等级</th>
            <th>累计佣金<br/>打款佣金</th>
            <th>下级下线</th>

            <th>注册时间</th>
            <th>审核时间</th>
            <th>状态</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        {loop $list $row}
        <tr>
            <td style="overflow: visible">
                <div rel="pop" data-content="
                <span>ID: </span>{$row['id']} </br>
                <span>推荐人：</span> {if empty($row['agentid'])}
				  {if $row['isagent']==1}
				      总店
				      {else}
				       暂无
				      {/if}
				{else}

                    	{if !empty($row['parentavatar'])}
                         <img class='radius50' src='{$row['parentavatar']}' style='width:20px;height:20px;padding1px;border:1px solid #ccc' onerror='this.src='../addons/ewei_shopv2/static/images/noface.png''/>
                       {/if}</br>
                       [{$row['agentid']}]{if empty($row['parentname'])}未更新{else}{$row['parentname']}{/if}
					   {/if}</br>
					   <span>是否关注：</span>
                         {if empty($row['followed'])}
                                {if empty($row['uid'])}
                               未关注
                                {else}
                               取消关注
                                {/if}
                                {else}
                               已关注
                                {/if} </br>
                            <span>状态:</span>  {if $row['isblack']==1}黑名单{else}正常{/if}

					   ">
                    {ifp 'member.list.view'}
                    <a href="{php echo webUrl('member/list/detail',array('id' => $row['id']));}" title='会员信息' target='_blank' style="display: flex">
                        <span data-toggle='tooltip' title='{$row['nickname']}'>
                        {if !empty($row['avatar'])}
                        <img class="radius50" src='{php echo tomedia($row['avatar'])}' style='width:30px;height:30px;padding1px;border:1px solid #ccc' onerror="this.src='../addons/ewei_shopv2/static/images/noface.png'"/>
                        {/if}
                        {if empty($row['nickname'])}未更新{else}{$row['nickname']}{/if}
                        </span>
                    </a>
                    {else}
                        <span data-toggle='tooltip' title='{$row['nickname']}'>
                        {if !empty($row['avatar'])}
                        <img class="radius50" src='{php echo tomedia($row['avatar'])}' style='width:30px;height:30px;padding1px;border:1px solid #ccc' onerror="this.src='../addons/ewei_shopv2/static/images/noface.png'"/>
                        {/if}
                        {if empty($row['nickname'])}未更新{else}{$row['nickname']}{/if}
                        </span>
                    {/if}
                </div>
            </td>

            <td>{$row['realname']} <br/> {$row['mobile']}</td>
            <td>{$level_name}</td>
            <td>{if $row['isagent']==1}
                {if empty($row['levelname'])} {php echo empty($this->set['levelname'])?'普通等级':$this->set['levelname']}{else}{$row['levelname']}{/if}</td>
            {else}
            -{/if}

            <td>{if $row['isagent']==1}
                {$row['commission_total']}<br/>{$row['commission_pay']}
                {else}
                -{/if}
            </td>
            <td >
                {ifp 'commission.agent.user'}
                <a class="_cover" href="{php echo webUrl('commission/agent/user',array('id' => $row['id'],'level' => 1));}"  target='_blank' data-toggle='popover' data-placement='right' data-html="true" data-trigger='hover' data-content='查看推广下线'>
                    {$row['levelcount']}
                </a>
                {else}
                {$row['levelcount']}
                {/if}

            </td>
            <td>{php echo date('Y-m-d',$row['createtime'])}<br/>{php echo date('H:i',$row['createtime'])}</td>
            <td>{if !empty($row['agenttime']) && $row['isagent']==1}
                {php echo date('Y-m-d',$row['agenttime'])}<br/>{php echo date('H:i',$row['agenttime'])}
                {else}
                -
                {/if}
            </td>
            <td>

                {if $row['isagent']==1}
                <span class='label {if $row['status']==1}label-primary{else}label-default{/if}'
                {ifp 'commission.agent.check'}
                data-toggle='ajaxSwitch'
                data-confirm ='确认要{if $row['status']==1}取消审核{else}审核通过{/if}?'
                data-switch-value='{$row['status']}'
                data-switch-value0='0|未审核|label label-default|{php echo webUrl('commission/agent/check',array('status'=>1,'id'=>$row['id']))}'
                data-switch-value1='1|已审核|label label-success|{php echo webUrl('commission/agent/check',array('status'=>0,'id'=>$row['id']))}'
                {/if}
                >
                {if $row['status']==1}已审核{else}未审核{/if}</span>
                <br/>


                <span class='label {if $row['agentblack']==1}label-default{else}label-primary{/if}'
                {ifp 'commission.agent.agentblack'}
                data-toggle='ajaxSwitch'
                data-switch-refresh='true'
                data-confirm ='确认要{if $row['agentblack']==1}取消{else}加入{/if}分销商黑名单?'
                data-switch-value='{$row['agentblack']}'
                data-switch-value0='0|正常|label label-primary|{php echo webUrl('commission/agent/agentblack',array('agentblack'=>1,'id'=>$row['id']))}'
                data-switch-value1='1|黑名单|label label-default|{php echo webUrl('commission/agent/agentblack',array('agentblack'=>0,'id'=>$row['id']))}'
                {/if}
                >
                {if $row['agentblack']==1}黑名单{else}正常{/if}</span>

                {else}
                -
                {/if}
            </td>


            <td  style="overflow:visible;">

                <div class="btn-group btn-group-sm">
                    {if $row['isagent']==1}
                        {ifp 'order.list'}
                        <a class="btn  btn-op btn-operation" href="{php echo webUrl('order/list',array('agentid' => $row['id']));}" title='推广订单'  target='_blank'>
                                        <span data-toggle="tooltip" data-placement="top" title="" data-original-title="推广订单">
                                            <i class='icow icow-tuiguang'></i>
                                        </span>
                        </a>
                        {/if}
                    {ifp 'commission.agent.delete'}
                    <a class="btn  btn-op btn-operation" data-toggle='ajaxRemove' href="{php echo webUrl('commission/agent/delete',array('id' => $row['id']));}" title="删除" data-confirm="确定要删除该分销商吗？">
                                       <span data-toggle="tooltip" data-placement="top" title="" data-original-title="删除分销商">
                                               <i class='icow icow-shanchu1'></i>
                                            </span>
                    </a>
                    {/if}
                    {/if}
                    {ifp 'order'}
                    <a class="btn  btn-op btn-operation" href="{php echo webUrl('order/list', array('searchfield'=>'member', 'keyword'=>$row['nickname'],'isprecise'=>1))}" title='会员订单'  target='_blank'>
                                     <span data-toggle="tooltip" data-placement="top" title="" data-original-title="会员订单">
                                        <i class='icow icow-dingdan2'></i>
                                    </span>
                    </a>
                    {/if}
                    {ifp 'finance.recharge.credit1|finance.recharge.credit2'}
                    <a class="btn  btn-op btn-operation" data-toggle="ajaxModal" href="{php echo webUrl('finance/recharge', array('type'=>'credit1','id'=>$row['id']))}" title='充值积分'>
                                    <span data-toggle="tooltip" data-placement="top" title="" data-original-title="充值">
                                       <i class='icow icow-31'></i>
                                    </span>
                    </a>
                    {/if}


                    </ul>
                </div>


            </td>
        </tr>
        {/loop}
        </tbody>
    </table>
    {$pager}

    {else}
    <div class='panel panel-default'>
        <div class='panel-body' style='text-align: center;padding:30px;'>
            暂时没有任何分销商!
        </div>
    </div>
    {/if}
    </form>
    </div>
    <script language="javascript">

        $(function () {
            $('[data-route="commission.agent"]').parent().addClass('active')
        })

        require(['bootstrap'],function(){
            $("[rel=pop]").popover({
                trigger:'manual',
                placement : 'right',
                title : $(this).data('title'),
                html: 'true',
                content : $(this).data('content'),
                animation: false
            }).on("mouseenter", function () {
                var _this = this;
                $(this).popover("show");
                $(this).siblings(".popover").on("mouseleave", function () {
                    $(_this).popover('hide');
                });
            }).on("mouseleave", function () {
                var _this = this;
                setTimeout(function () {
                    if (!$(".popover:hover").length) {
                        $(_this).popover("hide")
                    }
                }, 100);
            });




        });


    </script>


    {template '_footer'}